home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Utilities / Programming / EnterAct 3.7.3 / Drag_on Modules / hAWK programs / $EnteringFunction < prev    next >
Encoding:
Text File  |  1995-08-12  |  705 b   |  34 lines  |  [TEXT/KEEN]

  1. #$EnteringFunction: ad debugging to a hAWK program with functions,
  2. # inserting print statements at beginning of each function.
  3. # Pass it your problem program as the single input file:
  4. # overwrites the file.
  5. FNR == 1 {outfile = FILENAME}
  6.  
  7.     {
  8.     if (match($0, /^[ \t]*func/)) #start of function definition
  9.         {
  10.         name = $2
  11.         len = index(name, "(")
  12.         if (len+0 > 1)
  13.             name = substr(name,1,len-1)
  14.         out[++i] = $0
  15.         # Skip over opening left curly of function
  16.         if ($0 !~ /{/)
  17.             {
  18.             do
  19.                 {
  20.                 getline
  21.                 out[++i] = $0
  22.                 } while ($0 !~ /{/);
  23.             }
  24.         out[++i] = "print \"Entering: \"\"" name "\" ###"
  25.         }
  26.     else
  27.         out[++i] = $0
  28.     }
  29.  
  30. END {    close(outfile)
  31.         for (j = 1; j <= i; ++j)
  32.             print out[j] > outfile
  33.     }
  34.